import java.util.Arrays;

/**
 * @author Sebastian
 * @version 2.0
 * @date 2024/7/18 9:58
 */
// 最大数
    // https://leetcode.cn/problems/largest-number/description/
public class Solution179 {
    public String largestNumber(int[] nums) {
        String[] strNums = new String[nums.length];
        for (int i = 0; i < nums.length; i++) {
            strNums[i] = String.valueOf(nums[i]);
        }

        Arrays.sort(strNums, (s1, s2) -> (s2 + s1).compareTo(s1 + s2));
        String res = String.join("", strNums);
        return res.charAt(0) == '0' ? "0" : res;
    }
}
